﻿
Namespace PL.MESSDK
    Public Class Operation_PL
	Inherits PLBase

		Public Sub New()
			MyBase.New()
		End Sub
	
		Public Sub New(ByVal queryName As String)
			MyBase.New(queryName)
		End Sub
	
		Sub OnRowUpdating(ByVal sender As Object, ByVal e As SqlRowUpdatingEventArgs) Handles MetaDataTable.OnRowUpdating
	
		End Sub

		Public Overrides Function Delete() As Boolean
		   'Throw New NotImplementedException("Delete To Come...")
		   Return False
		End Function

		Public Overrides Function Validate() As Boolean
		   'Throw New NotImplementedException("Validate To Come...")
		   Return True
        End Function

        ''' <summary>
        ''' Validate a Operation DataRow
        ''' </summary>
        ''' <param name="row"></param>
        ''' <remarks>Errors are saved with row.SetColumnError method</remarks>
        Public Overrides Sub ValidateRow(row As DataRow)
            row.ClearErrors()

            If row.Table.Columns.Contains("OperationCd") Then
                If IsDBNull(row("OperationCd")) OrElse String.IsNullOrEmpty(row("OperationCd")) Then
                    row.SetColumnError("OperationCd", "Mandatory")
                End If
            End If

            If row.Table.Columns.Contains("OperationDescr_Prm") Then
                If IsDBNull(row("OperationDescr_Prm")) OrElse String.IsNullOrEmpty(row("OperationDescr_Prm")) Then
                    row.SetColumnError("OperationDescr_Prm", "Mandatory")
                End If
            End If

            If row.Table.Columns.Contains("OperationDescr_Alt") Then
                If IsDBNull(row("OperationDescr_Alt")) OrElse String.IsNullOrEmpty(row("OperationDescr_Alt")) Then
                    row.SetColumnError("OperationDescr_Alt", "Mandatory")
                End If
            End If

            If row.HasErrors Then
                row.RowError = "Please check your columns, a validation error occur"
            End If
        End Sub
    End Class
	End Namespace
